# Maintainer: Luca Weiss <luca@z3ntu.xyz>
pkgname=net-cpp
pkgver=3.1.0
pkgrel=0
pkgdesc="A simple yet beautiful networking API for C++11"
url="https://gitlab.com/ubports/core/lib-cpp/net-cpp"
arch="all"
license="LGPL-3.0-only"
makedepends="cmake cmake-extras boost-dev curl-dev process-cpp-dev
	properties-cpp-dev jsoncpp-dev gtest-dev samurai"
checkdepends="py3-httpbin"
subpackages="$pkgname-dev"
source="https://gitlab.com/ubports/core/lib-cpp/net-cpp/-/archive/$pkgver/net-cpp-$pkgver.tar.gz
	cxx17.patch
	python-init.patch
	"

build() {
	if [ "$CBUILD" != "$CHOST" ]; then
		CMAKE_CROSSOPTS="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	cmake -B build -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DBUILD_SHARED_LIBS=True \
		-DCMAKE_BUILD_TYPE=MinSizeRel \
		$CMAKE_CROSSOPTS .
	cmake --build build
}

check() {
	cd build
	CTEST_OUTPUT_ON_FAILURE=TRUE ctest
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

sha512sums="
a4e65651f1e31657e500cce71913bbc14cfe80fe55655d0b960abeb31ccea07e1343cd57c378b0d10ea18e4ce209e305ae4bd43206d4b5d6c3302328de294fb4  net-cpp-3.1.0.tar.gz
352fc4e3200360c1d91d025100ac33506ff705a2dd83f2d82eb8ed7426d78d1b3b5a6e548face39e17e09be63675ddcd61bb7b8f2af8ea6d299cf725c2127e68  cxx17.patch
b67b50f159438513f8744daec4cce23d335025cd5c213534c36e59a29e2aac4ecf749487ad73f855971a8431bbde514e295918177b6d07d253b901aaa28d8582  python-init.patch
"
